package com.bwie.controller;

import com.bwie.pojo.TbProd;
import com.bwie.service.TbOrderService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.PageOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/4/21 10:08
 */

@RestController
@RequestMapping("/order/index")
public class IndexController {

    @Autowired
    TbOrderService tbOrderService;

    /**
     * @description 根据ID获取订单信息
     * @params [id]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/21 10:10
     */
    @PostMapping("/getOrderById/{id}")
    public R getOrderById(@PathVariable("id") Integer id){
        return tbOrderService.getOrderById(id);
    }

    /**
     * @description 订单分页列表
     * @params [pageInfoVo]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/25 15:00
     */
    @PostMapping("/getOrderList")
    public R getOrderList(@RequestBody PageOrderVo pageInfoVo) {
        return tbOrderService.getOrderList(pageInfoVo);
    }

    /**
     * @description 下订单
     * @params []
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/4/26 14:54
     */
    @PostMapping("/addOrder")
    public R addOrder(@RequestBody List<TbProd> prodList) {
        return tbOrderService.addOrder(prodList);
    }

    /**
     * @description 短信发送测试工具类的接口
     * @params [mobile, code]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/5/7 15:25
     */
    @PostMapping("/sendMobileCode/{mobile}/{code}")
    public R sendMobileCode(@PathVariable("mobile") String mobile, @PathVariable("code") String code) {
        return tbOrderService.sendMobileCode(mobile, code);
    }

}
